
package sapat;

import java.sql.*;
public class conexion {

private Connection conexion;
 public Connection getConexion() {
    return conexion;
}    public void setConexion(Connection conexion) {
    this.conexion = conexion;
}

public conexion conectar() {
    try {
        Class.forName("oracle.jdbc.OracleDriver");
        String BaseDeDatos = "jdbc:oracle:thin:@jorge-HP:1521:XE";

        conexion = DriverManager.getConnection(BaseDeDatos,"System","jorge");
java.sql.Statement stmt = conexion.createStatement();
   

    if (conexion != null) {
            System.out.println("Conexion exitosa!");
            System.out.println( BaseDeDatos );
        } else {
            System.out.println("Conexion fallida!");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return this;

}
    public static void main(String[] args) {
     conexion f= new conexion();
        f.conectar();
    }
}
